package main

import (
	"fmt"
	"math/rand"
)

func main() {
	test02()
}

func test01() {

	var num int = rand.Intn(9) + 1
	for {
		fmt.Println("请输入一个1~10的数字：")
		var younum int
		fmt.Scanln(&younum)
		if younum == num {
			fmt.Printf("num=%d younum=%d, YOU WIN", num, younum)
			break
		} else {
			fmt.Printf("younum=%d, YOU LOSE, CONTINUE", younum)
		}

	}
}

func test02() {

	var count int = 0
	for {
		if count > 3 {
			fmt.Println("超过3次机会，不可再试")
			break
		}
		var name string
		var pass string
		fmt.Println("请输入用户名和密码：")
		scanln, err := fmt.Scanln(&name, &pass)
		if err != nil {
			return
		}
		fmt.Println(scanln)

		if name == "123" && pass == "123" {
			fmt.Println("SUCCESS")
			break
		}
		fmt.Printf("%s %sTRY !!!\n", name, pass)

		count++
	}
}
